package cate.game.admin.menu.custom;

import cate.common.table.d.GDCamp;
import cate.common.table.item.hero.row.HeroBaseRow;
import cate.game.GameBody;
import cate.game.admin.menu.MenuSetup;
import cate.game.role.Role;
import cate.game.role.bag.rune.Rune;


public class CustomMenu extends MenuSetup {

    public CustomMenu(GameBody gameBody) {
        super("自定义道具");
        reg(
                gameBody,
                "自定义徽章",
                3,
                "【参数1】技能1【参数2】技能2 【参数3】数量",
                (role, params) -> {
                    int skill1 = toInt(params, 0, 1000904);
                    int skill2 = toInt(params, 1, 1001004);
                    int num = toInt(params, 2, 1);
                    for (int i = 0; i < num; i++) {
                        Rune rune = buildTopRune(role,null, skill1, skill2);
                        role.getBag().rune.addItem(rune, null);
                    }
                    gameBody.notice.message(role, "成功!");
                });
    }

    public static Rune buildTopRune(Role role, HeroBaseRow heroTpl, int skill1, int skill2) {
        Rune rune = new Rune(role, 10006, 1);
        rune.level = 50;
        rune.initialize(role);
        rune.skillIds.clear();
        if (skill1 > 0) {
            rune.skillIds.add(skill1);
        }
        if (skill2 > 0) {
            rune.skillIds.add(skill2);
        }

        rune.attrIds.clear();
        rune.attrIds.add(20);
        rune.attrIds.add(28);
        rune.attrIds.add(37);

        rune.gradeAttrIds.add(107);
        int attrId = 204;
        if (heroTpl != null) {
            switch (heroTpl.camp){
                case GDCamp.Type.C1:attrId = 212;break;
                case GDCamp.Type.C2:attrId = 204;break;
                case GDCamp.Type.C3:attrId = 220;break;
                case GDCamp.Type.C4:attrId = 228;break;
                case GDCamp.Type.C5:attrId = 244;break;
                case GDCamp.Type.C6:attrId = 236;break;
                default:break;
            }
        }
        rune.gradeAttrIds.add(attrId);
        return rune;
    }
}
